package cn.smbms.controller;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import cn.smbms.pojo.User;

@Controller
public class IndexController {
	Logger logger = Logger.getLogger(IndexController.class);
	
	@RequestMapping("/index")
	public String index(){
		logger.info("hello,springMVC!");
		return "index";
	}
	
	@RequestMapping(value="/welcome")
	public String welcome(@RequestParam(value="username",required=false) String username){
		logger.info("welcome,"+username);
		return "index";
	}
	
	
	@RequestMapping("/index2")
	public String index1(String username,Model model){
		logger.info("welcome!username:"+username);
		model.addAttribute("username",username);
		model.addAttribute(username);
		User user = new User();
		user.setUserName(username);
		model.addAttribute("currentUser",user);
		model.addAttribute(user);
		return "index";
	}
}
